<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>箭头函数</title>
    <style>
    
    * {
        padding: 0;
        margin: 0;
    }

    .container {
        width: 300px;
        height: 100px;
        margin: 30px auto;
        border: 1px solid #ccc;
    }

    .box {
        width: 100px;
        height: 100px;
        background: #f40;
        margin-left: -100%;
        position: relative;
    }
    
    </style>
</head>
<body>
    
    <div class="container">
        <div class="box">

        </div>
    </div>
    

    <script>
        
        /*
        function fn (a){
            return function (b) {
                return a+b;
            }
        }

        console.log(fn(2)(3));

        // 转换成箭头函数

        let gn = a => b=>a+b ; // 高阶函数 (大于等于两个箭头)

        console.log(gn(2)(3));*/


        /* (function () {

            let p = new Promise((resolve,reject)=>{
                window.setTimeout(()=>{
                    let a = 10;
                    resolve(a);
                });
            });

            
            p.then((data)=> {
                console.log(data);
            },(err)=>{
                console.log(err);
            });

        })();


        -function () {
            function buy () {
                return new Promise((resolve,reject)=>{
                    setTimeout(() => {
                        if(Math.random()>0.5){
                            resolve('I Will take it');
                        }else {
                            reject("Sorry,I do not need that");
                        }
                    }, Math.random()*1000);
                });
            }

            buy().then((data)=>{
                console.log(data);
            },(err)=>{
                console.log(err);
            });
        } (); */


        /* (function () {

            class F {
                constructor (name) {
                    this.name = name;
                }

                fn () {
                    console.log(this);
                }
            }

            let f = new F("ws");

            f.fn();

        })(); */


        {
            // 箭头函数
        }



    </script>
</body>
</html>